/**
 * @param {string} s
 * @param {character} c
 * @return {number[]}
 */
 var shortestToChar = function(s, c) {
    const idx = [];
    const res = [];
    for (let i = 0; i < s.length; i++) {
        if (s[i] === c) {
            idx.push(i);
        }
    }
    idx.push(999999)
    let x=idx[0],y=idx[1],id=1;
    for (let i = 0; i < s.length; i++) {
    res.push(Math.min(Math.abs(x-i),Math.abs(y-i)))
        if(i===y){
            id++,x=y,y=idx[id]
        }
    }
    return res;
};